<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Strict//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'>
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
<title>荔香站- 统计死种</title>
</head>





<?php

$con = mysql_connect("10.110.2.17","root","zxxccccc");    //连接数据库

if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
mysql_select_db("discuzx", $con);     //数据库
mysql_query('set names gbk');    //数据库编码
$perNumber=200; //每页显示的记录数
$page=$_GET['page']; //获得当前的页面值
$count=mysql_query("SELECT count(*) FROM (select *,count(*) from pre_ctbit_zztj group by tid having count(*) >= (select times from pre_ctbit_tjtimes where id =9 )) as yy"); //获得记录总数
$rs=mysql_fetch_array($count); 
$totalNumber=$rs[0];
$totalPage=ceil($totalNumber/$perNumber); //计算出总页数

$x1 = "select times from pre_ctbit_tjtimes where id =9  ";   
$x2 = mysql_query($x1, $con); 
$x3 = mysql_fetch_array($x2);
 echo "统计次数:&nbsp;".$x3['times'];
 echo "&nbsp;&nbsp;&nbsp;统计天数:&nbsp;".ceil($x3['times']/3) ."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;初步死种数:".$totalNumber."&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;每天统计三次，分别是14:10, 19:10和23:40<br>
 ----------------------------------------------------------------------------------------------------------
 <br>";

if (!isset($page)) {
 $page=1;
} //如果没有值,则赋值1
$startCount=($page-1)*$perNumber; //分页开始,根据此方法计算出开始的记录
$result=mysql_query("select *,count(*) from pre_ctbit_zztj group by tid having count(*) >= (select times from pre_ctbit_tjtimes where id =9 ) ORDER BY COUNT( * ) DESC limit $startCount,$perNumber"); //根据前面的计算出开始的记录和记录数
while ($row=mysql_fetch_array($result)) {
 echo "<a href='http://res.hltz.net/zyq17/m".$row['tid']."' target='_blank'>".$row['filename']."</a>";
 echo "&nbsp;&nbsp;&nbsp;没种天数:".ceil($row['count(*)']/3) ."<br>
 ----------------------------------------------------------------------------------------------------------
 <br>"; //显示数据库的内容
}
if ($page != 1) { //页数不等于1
?>
<a href="/tj.php?page=<?php echo $page - 1;?>">上一页</a> <!--显示上一页-->
<?php
}
for ($i=1;$i<=$totalPage;$i++) {  //循环显示出页面
?>
<a href="/tj.php?page=<?php echo $i;?>"><?php echo $i ;?></a>
<?php
}
if ($page<$totalPage) { //如果page小于总页数,显示下一页链接
?>
<a href="/tj.php?page=<?php echo $page + 1;?>">下一页</a>
<?php
} 
?>